<?php
function getKeywordID($keyword)
{
	$arr = array('alex', '电影票', 'QQ仔');
	$fp = fopen('te.txt', 'w');
	foreach ($arr as $val) {
		fwrite($fp, $val."\n");	
	}
	fclose($fp);
	echo '----------------',ChickC(file_get_contents('key_conv.txt')); 

	$str = substr(md5($keyword), 0, 16);
	$hexstr = '';
	for ($i = 7; $i >= 0; $i--) {
		$tmp = substr($str, $i * 2, 2);
		$hexstr .= $tmp;
	}
	$hexstr = dechex(intval(substr($hexstr, 0, 2), 16) & 0x7F) . substr($hexstr, 2, 14);
	return intval($hexstr, 16);
}


$arr = array('alex', '电影票', 'QQ仔');

foreach ($arr as $val) {
//	echo $val;
	echo $val , '=>' , getKeywordID($val), "\n";
}
function ChickC($str)
{
$array = array('ASCII','GBK','UTF-8');
foreach ($array as $value)
{
if ($str === mb_convert_encoding(mb_convert_encoding($str, "UTF-32", $value), $value, "UTF-32"))
return $value;
}
return false;
} 


